home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Sysmon120a.lha / sysmon / include / sysmon.i < prev   
Text File  |  2002-03-10  |  15KB  |  387 lines

  1. **    sysmon.i
  2. **
  3. **      $Filename: sysmon.i $
  4. **      $Revision: 1.16 $
  5. **      $Date: 2001/04/28 14:12:44 $
  6. **
  7. *******************************************************************************
  8. **    definition of sysmon.library base and internal structures (version 1.18)
  9. *******************************************************************************
  10. **
  11. **    Copyright (c) 1995-2002 by Etienne Vogt.
  12. **
  13.  
  14.     IFND    SYSMON_I
  15. SYSMON_I    SET    1
  16.  
  17.     IFND    EXEC_LIBRARIES_I
  18.     INCLUDE    "exec/libraries.i"
  19.     ENDC
  20.  
  21.     IFND    EXEC_SEMAPHORES_I
  22.     INCLUDE    "exec/semaphores.i"
  23.     ENDC
  24.  
  25.     IFND    EXEC_MEMORY_I
  26.     INCLUDE    "exec/memory.i"
  27.     ENDC
  28.  
  29.     IFND    DEVICES_TIMER_I
  30.     INCLUDE    "devices/timer.i"
  31.     ENDC
  32.  
  33.     IFND    DOS_DATETIME_I
  34.     INCLUDE    "dos/datetime.i"
  35.     ENDC
  36.  
  37. * library data structure
  38. * All field in the SysmonBase structure are PRIVATE !!!
  39. * Don't access these directly as they will change in future versions.
  40. * You have been warned !!!
  41.  
  42. HASHSIZE    EQU    32
  43. HASHMASK    EQU    $f8
  44.  
  45.  STRUCTURE SysmonBase,LIB_SIZE            ; Standard lib node
  46.     UBYTE    sb_Flags            ; Some flags here
  47.     UBYTE    sb_pad                ; We are now longword aligned
  48.     APTR    sb_ExecBase            ; Pointer to exec
  49.     APTR    sb_UtilityBase            ; Pointer to utility
  50.     BPTR    sb_SegList            ; SegList BCPL pointer
  51.     APTR    sb_CurrTaskInfo            ; Current TaskInfo Structure
  52.     APTR    sb_Switch            ; Original Switch() entry point
  53.     APTR    sb_Dispatch            ; Original Dispatch() entry point
  54.     APTR    sb_AddTask            ; Original AddTask() entry point
  55.     APTR    sb_RemTask            ; Original RemTask() entry point
  56.     APTR    sb_FindTask            ; Original FindTask() entry point
  57.     APTR    sb_Alert            ; Original Alert() entry point
  58.     APTR    sb_ExitIntr            ; Original ExitIntr() entry point
  59.     APTR    sb_Schedule            ; Original Schedule() entry point
  60.     APTR    sb_Exception            ; Original Exception() entry point
  61.     APTR    sb_SetTaskPri            ; Original SetTaskPri() entry point
  62.     APTR    sb_SetExcept            ; Original SetExcept() entry point
  63.     APTR    sb_SetSignal            ; Original SetSignal() entry point
  64.     APTR    sb_Signal            ; Original Signal() entry point
  65.     APTR    sb_Wait                ; Original Wait() entry point
  66.     APTR    sb_TaskExit            ; Original ExecBase->TaskExitCode
  67.     APTR    sb_TaskExcept            ; Original ExecBase->TaskExceptCode
  68.     APTR    sb_TaskTrap            ; Original ExecBase->TaskTrapCode
  69.     STRUCT    sb_TimeReq,IOTV_SIZE        ; Time Request
  70.     STRUCT    sb_TempTime,EV_SIZE        ; Temporary EClock Time
  71.     STRUCT    sb_TaskFrozen,LH_SIZE        ; List of frozen tasks
  72.     BYTE    sb_ResetBit            ; Signal bit for reset handler
  73.     UBYTE    sb_ResetFlags            ; Flags for reset handler
  74.     STRUCT    sb_TaskInfoHash,4*HASHSIZE    ; TaskInfo hash table
  75.     APTR    sb_ServerEntry            ; Server process entry point
  76.     APTR    sb_ServerName            ; Server process name
  77.     APTR    sb_SyslogFile            ; SysLog file name
  78.     APTR    sb_SyslogWindow            ; Syslog Window Name
  79.     UBYTE    sb_FilePri            ; File logging priority
  80.     UBYTE    sb_WindowPri            ; Window logging priority
  81.     UBYTE    sb_ConsolePri            ; Console logging priority
  82.     UBYTE    sb_NumLogBuffers        ; Number of allocated Buffers
  83.     APTR    sb_Buffers            ; Pointer to allocated buffers
  84.     APTR    sb_DOSBase            ; Pointer to dos
  85.     APTR    sb_DateTime            ; struct DateTime used by syslog
  86.     ULONG    sb_StampPeriod            ; Period for syslog file stamp
  87.     BPTR    sb_LogWindowHandle        ; LogWindow file handle
  88.     APTR    sb_IntuitionBase        ; Pointer to intuition
  89.     APTR    sb_LastGuru            ; Pointer to LastGuru structure
  90.     APTR    sb_SyslogPort            ; Pointer to Syslog MsgPort
  91.     APTR    sb_ServerProc            ; Pointer to server process
  92.     APTR    sb_ResetHandler            ; Pointer to reset handler
  93.     APTR    sb_ResetReq            ; Pointer to reset request
  94.     STRUCT    sb_BCPSem,SS_SIZE        ; Semaphore for Broadcast Ports list
  95.     STRUCT    sb_BroadcastPorts,MLH_SIZE    ; List of Registered Broadcast Ports
  96.     STRUCT    sb_TTASem,SS_SIZE        ; Semaphore for Task Table Access
  97.     STRUCT    sb_TTRSem,SS_SIZE        ; Semaphore for Task Table Removal
  98.     STRUCT    sb_CPUTime,EV_SIZE        ; Total CPU Time used by tasks
  99.     APTR    sb_MMUBase            ; Pointer to mmu library
  100.     APTR    sb_ColdReboot            ; Cached ColdReboot() vector
  101.     ULONG    sb_VolTSw            ; Voluntary Task Switches counter
  102.     ULONG    sb_InvTSw            ; Involuntary Task Switches counter
  103.     STRUCT    sb_LdAvrVBLInt,IS_SIZE        ; Load Average VBL Interrupt
  104.     UWORD    sb_LdAvrPtr            ; Pointer in Load Average circular buffer
  105.     STRUCT    sb_LdAvrBuffer,15*60        ; Load Average circular Buffer, updated every
  106.                         ; second from the sysmon.library VBlank interrupt
  107.     ULONG    sb_QuantumExp            ; Global Quantum Expiration counter
  108.     APTR    sb_SuperState            ; Original SuperState() entry point
  109.     APTR    sb_UserState            ; Original UserState() entry point
  110.  LABEL   SysmonBase_SIZEOF
  111.  
  112. * The TaskInfo structure contains the CPU usage information in EClock ticks.
  113. * The link pointers are private and should not be used. Use the smNextTaskInfo()
  114. * function to traverse the list.
  115. * This structure may be extended later with new fields. Also all fields are
  116. * strictly READ ONLY.
  117.  
  118.  STRUCTURE TaskInfo,0
  119.     APTR    ti_Link                ; private pointer to next TaskInfo
  120.     APTR    ti_Pred                ; private pointer to previous TaskInfo
  121.     APTR    ti_Task                ; pointer to Task Control Block
  122.     ULONG    ti_DispCount            ; Task Dispatch counter
  123.     STRUCT    ti_StartTime,EV_SIZE        ; Starting EClock Time
  124.     STRUCT    ti_LaunchTime,EV_SIZE        ; Last Launch Time
  125.     STRUCT    ti_CPUTime,EV_SIZE        ; Cumulated CPU Time
  126.     UBYTE    ti_Flags            ; Various flags
  127.     UBYTE    ti_ExcptState            ; Task State saved by Exception()
  128.     BYTE    ti_EDNestCnt            ; Exception Disable Nest Count
  129.     UBYTE    ti_FreezeState            ; Task State saved by smFreeze()
  130.     ULONG    ti_VolTSw            ; Voluntary Task Switches counter
  131.     ULONG    ti_InvTSw            ; Involuntary Task Switches counter
  132.     ULONG    ti_QuantumExp            ; Quantum Expiration counter
  133.  LABEL    TaskInfo_SIZEOF
  134.     
  135. * ti_Flags bits
  136.  
  137.     BITDEF    TI,INEXCEPT,0            ; Task is inside Exception code
  138.     BITDEF    TI,WAKEUP,1            ; A WakeUp request is pending
  139.  
  140. * This is the private structure used by smVSysLog() to communicate with the
  141. * Sysmon.server process.
  142.  
  143. SM_MAXLOGCHARS    EQU    256            ; Max bytes in SysLog message
  144.  
  145.  STRUCTURE SysLogMsg,MN_SIZE            ; Message structure
  146.     ULONG    slm_Priority            ; SysLog priority and flags
  147.     STRUCT    slm_Text,SM_MAXLOGCHARS        ; Syslog Message body
  148.  LABEL    SysLogMsg_SIZEOF
  149.  
  150. SYSMONNAME    MACRO
  151.     DC.B    'sysmon.library',0
  152.     ENDM
  153.  
  154. SERVERNAME    MACRO
  155.     DC.B    'Sysmon.server',0
  156.     ENDM
  157.  
  158. * sb_Flags bits
  159.  
  160.     BITDEF    SBF,FPU,0            ; System has a FPU
  161.     BITDEF    SBF,IDLELED,1            ; Dim power LED when CPU is idle
  162.     BITDEF    SBF,MMU,2            ; System has a MMU (according to mmu.library)
  163.     BITDEF    SBF,MACOSKLUDGE,3        ; Try to be friendly to MacOS emulators
  164.     BITDEF    SBF,SUPERSTATE,7        ; PRIVATE flag for smSuperState()
  165.  
  166. * sb_ResetFlags bits
  167.  
  168.     BITDEF    SBRST,ACTIVATE,0        ; Activate reset handler
  169.     BITDEF    SBRST,PENDING,1            ; Reset is pending
  170.     BITDEF    SBRST,OLDMMU,2            ; Restore old MMU setup before reboot
  171.     BITDEF    SBRST,CACHEREBOOT,3        ; Use a cached ColdReboot() vector
  172.  
  173. * Alert definitions
  174. * These are the Guru codes that sysmon.library can spit out in a panic
  175. * condition.
  176.  
  177. AN_Sysmon    EQU    $40000000    ; SubSystem ID
  178. AN_smNoTaskInfo    EQU    $40000001    ; No TaskInfo structure for this task
  179. AN_smNoTIMem    EQU    $40010002    ; No mem for TaskInfo at startup
  180. AN_smSysLogBuf    EQU    $40010003    ; No memory for syslog buffers
  181. AN_BadSysLogMsg    EQU    $40000004    ; Bad SysLogMsg received by server
  182. AN_smNoLastGuru    EQU    $40010005    ; No memory for LastGuru buffer
  183. AN_smNoAlertMem    EQU    $40010006    ; No memory for new alert.hook module
  184. AN_smSuperTaskSwitch EQU $C0000007    ; Attempt to switch task from supervisor mode
  185. AN_smInconSchedState EQU $C0000008    ; Inconsistant Scheduling State
  186. AO_Sysmon    EQU    $00008040    ; Alert object
  187.  
  188. * These are reused obsolete exec alert codes
  189.  
  190. AN_UnInitExcpt    EQU    $0100000A    ; Uninitialized task exception (not CPU trap)
  191.  
  192. * New Task States Definitions (not all used yet !)
  193. * TS_STOP is not a real state. It is used by ShowSys to identify tasks that
  194. * are stuck in a Wait(0) call, such as crashed tasks that have been suspended.
  195.  
  196. TS_STOP        EQU    $80        ; Stopped task (Wait(0L))
  197. TS_FROZEN    EQU    $81        ; Frozen task
  198. TS_HIBERNATE    EQU    $82        ; Hibernating task
  199. TS_PAGEFLTWAIT    EQU    $83        ; Task suspended for page fault processing
  200. TS_WAITAND    EQU    $84        ; Task waiting for several signals set together
  201. TS_TRAP        EQU    $85        ; Task suspended by exception trap code
  202. TS_FREEWAIT    EQU    $86        ; Task waiting for free memory
  203.  
  204. * SysLog priorities and flags
  205. * The priorities are similar to that used on UNIX systems. This means that
  206. * the values use the UNIX ordering that is reversed from the Amiga one.
  207. * The facilities are also UNIX like and indicate what part of the system
  208. * produced the message. This is purely informational currently.
  209. * The flags are Amiga and sysmon specifics.
  210.  
  211. * Priorities
  212.  
  213. LOG_EMERG    EQU    0        ; Panic condition (Guru time)
  214. LOG_ALERT    EQU    1        ; Very serious problem
  215. LOG_CRIT    EQU    2        ; Critical error
  216. LOG_ERR        EQU    3        ; General error condition
  217. LOG_WARN    EQU    4        ; Warning condition
  218. LOG_NOTICE    EQU    5        ; Noticeable event
  219. LOG_INFO    EQU    6        ; General informational event
  220. LOG_DEBUG    EQU    7        ; Debugging information
  221. LOG_PRI        EQU    $7        ; Mask for priority field
  222.  
  223. * Facilities
  224.  
  225. LOG_NOFAC    EQU    (0<<3)        ; no facility
  226. LOG_KERN    EQU    (1<<3)        ; kernel/system messages
  227. LOG_USER    EQU    (2<<3)        ; random user-level messages
  228. LOG_MAIL    EQU    (3<<3)        ; mail system
  229. LOG_DAEMON    EQU    (4<<3)        ; system daemons/commodities
  230. LOG_AUTH    EQU    (5<<3)        ; security/authorization messages
  231. LOG_SYSLOG    EQU    (6<<3)        ; messages generated internally by Syslog
  232. LOG_NEWS    EQU    (7<<3)        ; network news subsystem
  233. LOG_UUCP    EQU    (8<<3)        ; UUCP subsystem
  234. LOG_CRON    EQU    (9<<3)        ; cron/queue_manager subsystem
  235. LOG_AUTHPRIV    EQU    (10<<3)        ; private security/authorization messages
  236. LOG_FTP        EQU    (11<<3)        ; ftp daemon
  237. * other codes through 15 reserved for system use
  238. LOG_LOCAL0    EQU    (16<<3)        ; reserved for local use
  239. LOG_LOCAL1    EQU    (17<<3)        ; reserved for local use
  240. LOG_LOCAL2    EQU    (18<<3)        ; reserved for local use
  241. LOG_LOCAL3    EQU    (19<<3)        ; reserved for local use
  242. LOG_LOCAL4    EQU    (20<<3)        ; reserved for local use
  243. LOG_LOCAL5    EQU    (21<<3)        ; reserved for local use
  244. LOG_LOCAL6    EQU    (22<<3)        ; reserved for local use
  245. LOG_LOCAL7    EQU    (23<<3)        ; reserved for local use
  246. LOG_MARK    EQU    (24<<3)        ; special time stamp mark
  247. LOG_UNKNOWN    EQU    (25<<3)        ; unknown facility code
  248. LOG_FAC        EQU    $03f8        ; Mask for facility field
  249.  
  250. * Flags
  251.  
  252. LOG_INUSE    EQU    $80000000    ; Message is in use (private !)
  253. LOG_NOHEAD    EQU    $40000000    ; Don't prepend header
  254. LOG_NOWIN    EQU    $20000000    ; Don't output to window
  255. LOG_NOFILE    EQU    $10000000    ; Don't output to file
  256.  
  257. LOGB_INUSE    EQU    31        ; Bit numbers for flags
  258. LOGB_NOHEAD    EQU    30
  259. LOGB_NOWIN    EQU    29
  260. LOGB_NOFILE    EQU    28
  261.  
  262.  
  263. * Flags definitions for smHalt()
  264.  
  265.     BITDEF    HALT,REBOOT,0        ; Reboot immediately
  266.     BITDEF    HALT,REKICK,1        ; Reload kickstart on MMU-Kicked systems.
  267.  
  268. * Broadcast Message send via smSendBroadcastMsg()
  269. * The sender must allocate this structure and fill in the different fields.
  270.  
  271.  STRUCTURE BroadcastMsg,MN_SIZE            ; Standard Message structure
  272.     UBYTE    bcm_Level            ; Event Level
  273.     UBYTE    bcm_Flags            ; Flags
  274.     UWORD    bcm_TimeOut            ; Reply Time Out in ticks
  275.     UWORD    bcm_CountDown            ; Countdown to Event in seconds
  276.     UBYTE    bcm_ReplyCount            ; Reply count after sending
  277.     UBYTE    bcm_TimeOutCount        ; Time Out count after sending
  278.     APTR    bcm_SenderTask            ; Sender Task (Filled by smSendBroadCastMsg())
  279.     APTR    bcm_EventTxt            ; Text describing the event
  280.     STRUCT    bcm_Reserved,4*4        ; Reserved for future expansion
  281.  LABEL    BCM_SIZEOF
  282.  
  283. * defines for event levels
  284.  
  285. BCM_HALT    EQU    0        ; System Halt/Reboot imminent
  286. BCM_UNMOUNT    EQU    1        ; FileSystems will be UnMounted now
  287. BCM_SHUTDOWN    EQU    2        ; Shutdown countdown message
  288. BCM_URGENT    EQU    3        ; Urgent Message 
  289. BCM_NORMAL    EQU    4        ; Normal Message
  290. BCM_DEBUG    EQU    5        ; Debug Level Message
  291.  
  292. * defines for bcm_Flags
  293.  
  294.     BITDEF    BCM,DOOMSDAY,0        ; Keyboard reset pending (System reboot in 10 seconds at most)
  295.     BITDEF    BCM,CANCEL,1        ; A previously announced event has been cancelled
  296.  
  297. * defines for smLockTaskTable()/smUnLockTaskTable() flags
  298.  
  299.     BITDEF    LTT,READ,0        ; Read access to task table
  300.     BITDEF    LTT,WRITE,1        ; Write access (PRIVATE !)
  301.     BITDEF    LTT,REMOVE,2        ; Prevent task removal
  302.  
  303.  
  304. * The LastGuru structure contains information about the last Guru Meditation
  305. * The data is stored in a high memory buffer by Alert() that is allocated by
  306. * sysmon.library during initialisation.
  307. * As this buffer is allocated early with AllocMem(MEMF_REVERSE), it will be
  308. * kept at the same address after reboot. This trick was already used successfully
  309. * on recoverable ram disks like vdisk.device
  310. * Some Fields are only valid if the corresponding register exists on the CPU
  311. * installed in the system.
  312.  
  313.  STRUCTURE LastGuru,MC_SIZE        ; leave space for a memory chunk
  314.     ULONG    lg_Sig            ; Alert signature ('HELP')
  315.     ULONG    lg_AlertNum        ; Guru Meditation number
  316.     ULONG    lg_AlertAddr        ; TCB Address of crashed task
  317.     STRUCT    lg_TaskName,32        ; Task name limited to 32 bytes
  318.     STRUCT    lg_DataRegs,8*4        ; Data registers D0-D7
  319.     STRUCT    lg_AddrRegs,8*4        ; Address registers A0-A7
  320.     STRUCT    lg_FloatRegs,8*12    ; Floating point registers FP0-FP7
  321.     ULONG    lg_FPCR            ; Floating Point Control Register
  322.     ULONG    lg_FPSR            ; Floating Point Status Register
  323.     ULONG    lg_FPIAR        ; Floating Point Instruction Address Register
  324.     ULONG    lg_PC            ; Program Counter
  325.     ULONG    lg_USP            ; User Stack Pointer
  326.     ULONG    lg_SSP            ; Supervisor/Interrupt Stack Pointer
  327.     ULONG    lg_MSP            ; Master Stack Pointer / Processor Control Register [68060]
  328.     ULONG    lg_VBR            ; Vector Base Register
  329.     ULONG    lg_SFC            ; Source Function Codes
  330.     ULONG    lg_DFC            ; Destination Function Codes
  331.     ULONG    lg_CACR            ; Cache Control Register
  332.     ULONG    lg_TC            ; Translation Control register
  333.     ULONG    lg_ITT0            ; Intruction Transparent Translation 0
  334.     ULONG    lg_ITT1            ; Intruction Transparent Translation 1
  335.     ULONG    lg_DTT0            ; Data Transparent Translation 0 / Common Root Pointer [68030]
  336.     ULONG    lg_DTT1            ; Data Transparent Translation 1 / Common Root Pointer [68030]
  337.     ULONG    lg_URP            ; User Root Pointer / Supervisor Root Pointer [68030]
  338.     ULONG    lg_SRP            ; Supervisor Root Pointer
  339.     ULONG    lg_MMUSR        ; MMU Status Register / Bus Control Register [68060]
  340.     ULONG    lg_CAAR            ; Cache Address Register
  341.     UWORD    lg_SR            ; Status Register
  342.     UWORD    lg_AC            ; Access Control register [68851]
  343.     STRUCT    lg_DRP,8        ; DMA Root Pointer [68851]
  344.     STRUCT    lg_BAD,8*2        ; Breakpoint Acknowledge Data registers [68851]
  345.     STRUCT    lg_BAC,8*2        ; Breakpoint Acknowledge Control registers [68851]
  346.     UBYTE    lg_CAL            ; Current Access Level [68851]
  347.     UBYTE    lg_VAL            ; Valid Access Level [68851]
  348.     UBYTE    lg_SCC            ; Stack Change Control register [68851]
  349.     UBYTE    lg_Pad            ; Padding byte
  350.  LABEL lg_SizeOf
  351.  
  352.  
  353. * Function LVOs
  354.  
  355.     INCLUDE "exec/funcdef.i"
  356.  
  357.     FUNCINIT
  358.     FUNCDEF    smGetTaskInfo
  359.     FUNCDEF    smFreeze
  360.     FUNCDEF    smUnFreeze
  361.     FUNCDEF    smSleep
  362.     FUNCDEF    smVKPrintf
  363.     FUNCDEF    smVSPrintf
  364.     FUNCDEF    smVSysLog
  365.     FUNCDEF    smFindTaskInfo
  366.     FUNCDEF    smNextTaskInfo
  367.     FUNCDEF    smHalt
  368.     FUNCDEF smVSnPrintf
  369.     FUNCDEF smFindNode
  370.     FUNCDEF    smAddBroadcastPort
  371.     FUNCDEF    smRemBroadcastPort
  372.     FUNCDEF    smSendBroadcastMsg
  373.     FUNCDEF    smGetVBR
  374.     FUNCDEF    smMoveVBR
  375.     FUNCDEF smLockTaskTable
  376.     FUNCDEF    smUnLockTaskTable
  377.     FUNCDEF    smDisallowExcept
  378.     FUNCDEF    smAllowExcept
  379.     FUNCDEF    smHibernate
  380.     FUNCDEF    smWakeUp
  381.     FUNCDEF    smScheduleWakeUp
  382.     FUNCDEF    smEndExcept
  383.     FUNCDEF    smWaitAnd
  384.  
  385.    ENDC  ;SYSMON_I
  386.  
  387.